import request from "@/utils/request.js";

export const dictApi = {
    // 获取字典项
    getDictItems: (code) => request.get(`/sysDict/items/${code}`),
    
    // 分页查询字典类型
    getPage: (params) => request.get('/sysDict/page', { params }),
    
    // 获取字典类型详情
    getById: (id) => request.get(`/sysDict/info/${id}`),
    
    // 创建字典类型
    create: (data) => request.post('/sysDict', data),
    
    // 更新字典类型
    update: (data) => request.put('/sysDict', data),
    
    // 删除字典类型
    delete: (id) => request.delete(`/sysDict/${id}`),
    
    // 批量删除字典类型
    deleteBatch: (ids) => request.delete('/sysDict/batch', {
        params: {
            ids: ids.join(',')
        }
    }),
    
    // 根据字典ID获取字典项列表
    getDictItemsByDictId: (dictId) => request.get(`/sysDict/items/dict/${dictId}`),
    
    // 创建字典项
    createDictItem: (data) => request.post('/sysDict/item', data),
    
    // 更新字典项
    updateDictItem: (data) => request.put('/sysDict/item', data),
    
    // 批量更新字典项
    updateDictItemsBatch: (data) => request.put('/sysDict/items/batch', data),
    
    // 删除字典项
    deleteDictItem: (id) => request.delete(`/sysDict/item/${id}`)
}